<tagLib name="html" />
<include file="Public:header" />
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
  
<!--  功能组区域  -->
<div class="btn-toolbar">
      <div class="btn-group">
        <button class="btn btn-primary" onclick="add({$_GET.enter_id})"><i class="icon-plus icon-white"></i> 新增</button>
        <button class="btn btn-primary" onclick="edit()"><i class="icon-edit icon-white"></i> 编辑</button>
  	   <button class="btn btn-primary" onclick="print()"><i class="icon-print icon-white"></i> 打印入库单</button>
        <button class="btn btn-primary" onclick="foreverdel()"><i class="icon-trash icon-white"></i> 删除</button>
      </div>
<form class="search-form pull-right" method='get' action="__URL__">
          {:modList('Supplier',$_REQUEST['supplier_id'])}
        入库单号  <input type="text" name="enter_no" class="span2" value="{$_REQUEST.enter_no}" />
             产品 <input type="text" class="search-query span4" name="keywords" <notempty name='_REQUEST.keywords'>
                    <php>echo 'value="'.urldecode($_REQUEST['keywords']).'"'</php><else/>
                    placeholder="按产品名称，搜索"
                </notempty> >
                <span class="label lable-info">关键词+空格+关键词 查询</span>
                <input type="submit" class="btn btn-primary" value="搜索">
    </form>
  </div>
<!-- 功能组区域结束 -->
<php>
    function getUser($enter_id){
        return getModelName($enter_id,'User');
    }
</php>
<!-- 列表显示区域  -->
<div class="list" >
<div id="result" class="result none"></div>
  <notempty name="_REQUEST.enter_id">
    <php>
      $eid = $_REQUEST['enter_id'];
      $enter = M('Enter');
      $enter->getById($eid);
      $total_number = M('Enter_detail')->where('enter_id = '.$eid)->sum('number');
      $enter_no = $enter->enter_no;
      $total = $enter->total;
      $supplier = $enter->supplier_id;
      $user_id = $enter->user_id;
      $create_time = $enter->create_time;
    </php>
  <p class="h4 span12 alert-info alert"><strong>采购单号:</strong> {$enter_no}  <strong>总数量</strong>: {$total_number}  <strong>总金额：</strong>{$total}元   <strong>供应商:</strong>{$supplier|getModelName="Supplier"}    <strong>经办人：</strong>{$user_id|getModelName="User"}    <strong>采购时间:</strong>{$create_time|toDate}
  </p> 
  </notempty>

<html:list id="checkList" pk="did" style="table table-bordered table-striped" name="action" checkbox="true" action="true" datasource="list" show="did:编号|3%:edit,enter_no:入库单号,name:产品,enter_price:进价,number:数量,dtotal:总金额,sname:供应商,wname:仓库,pid|getDStock:当前库存,dctime|toDate:录入时间,user_id|getUser:经办人" actionlist="edit:编辑:did" />
</div>
<!--  分页显示区域 -->
<div class="page">{$page}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<!-- 主页面结束 -->
<include file="Public:footer"/>
<script type="text/javascript">

  function print(){
    var keyValue;
      keyValue = {$_REQUEST.enter_id};
    if (!keyValue)
    {
      alert('请选择入库单！');
      return false;
    }
    location.href=APP+"/Enter/print_enter/id/"+keyValue;
    
 }
</script>
